<template>
    <div class="container">
        <!--数据大屏展示区-->
        <div class="screen" ref="screen">
            <div class="nav">
                <Top></Top>
            </div>
            <div class="main">
                <div class="m-left">
                    <div class="tourist">
                        <Tourist></Tourist>
                    </div>
                    <div class="sex">
                        <Sex></Sex>
                    </div>
                    <div class="age">
                        <Age ></Age>
                    </div>    
                </div>
                <div class="m-center">
                    <div class="map">
                        <div class="map">
                            <Map></Map>
                        </div>
                        <div class="line">
                            <Line></Line>
                        </div>
                    </div>
                </div>
                <div class="m-right">
                    <div class="rank">
                        <Rank></Rank>
                    </div>
                    <div class="year">
                        <Year></Year>
                    </div>
                    <div class="couter">
                        <Couter></Couter>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
//引入顶部的子组件
import Top from './components/top/index.vue'
//引入左侧三个组件
import Tourist from './components/tourist/index.vue'
import Sex from './components/sex/index.vue'
import Age from './components/age/index.vue'
import Map from './components/map/index.vue'
import Line from './components/line/index.vue'
import Rank from './components/rank/index.vue'
import Year from './components/year/index.vue'
import Couter from './components/couter/index.vue'


//获取数据大屏展示区DOM元素
let screen = ref()

//定义大屏缩放比例
const getScale = (w = 1920, h = 1080) => {
    let ww = window.innerWidth / w
    let wh = window.innerHeight / h
    return ww < wh ? ww : wh
}

onMounted(() => {
    screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
})

//监听视口变化
window.onresize = () => {
    screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
}
</script>

<style scoped lang="scss">
.container {
    width: 100vw;
    height: 100vh;
    background: url(./images/bg.png) no-repeat;
    background-size: cover;

    .screen {
        position: fixed;
        width: 1920px;
        height: 1080px;
        left: 50%;
        top: 50%;
        transform-origin: left top;

        .nav {
            width: 100%;
            height: 42px;
        }

        .main {
            display: flex;
            width: 100%;

            .m-left {
                height: 1038px;
                flex: 1;
                display: flex;
                flex-direction: column;

                .tourist {
                    box-sizing: border-box;
                    height: 397px;
                }

                .sex {
                    box-sizing: border-box;
                    height: 337px;
                }

                .age {
                    box-sizing: border-box;
                    height: 304px;
                }
            }

            .m-center {
                flex: 2.5;
                margin-top: 32px;
                display: flex;
                flex-direction: column;

                .map {
                    box-sizing: border-box;
                    height: 715px;
                }

                .line {
                    box-sizing: border-box;
                    height: 291px;
                }
            }

            .m-right {
                height: 1038px;
                flex: 1;
                display: flex;
                flex-direction: column;

                .rank {
                    box-sizing: border-box;
                    height: 397px;
                }

                .year {
                    box-sizing: border-box;
                    height: 337px;
                }

                .couter {
                    box-sizing: border-box;
                    height: 304px;
                }
            }
        }
    }
}
</style>